package com.witframework.web.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.witframework.core.resource.SpringResourceBundle;
import com.witframework.util.HtmlBuilder;

public class SearchButtonTag extends TagSupport{
	private String type="submit";
	private String styleClass="searchButton";
	private String label="搜 索";
	
	@Override
	public int doStartTag() throws JspException {			
		HtmlBuilder html=new HtmlBuilder();
		html.input().type(type);
		html.onclick("queryEc(document.forms[0]);ajaxAnywhere.submitAJAX(); return false;");
		html.styleClass(styleClass);
		html.value(getLabel());
		html.close();

		JspWriter writer = pageContext.getOut();
		try {			
			writer.println(html.toString());
		} catch (IOException e) {
			throw new JspException("Print/Flush in LoadingTag tag error:" + e);
		}
		return (EVAL_BODY_INCLUDE);
	}	
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getStyleClass() {
		return styleClass;
	}
	public void setStyleClass(String styleClass) {
		this.styleClass = styleClass;
	}
	public String getLabel() {
		return label;
	}
	public void setLabel(String label) {
		SpringResourceBundle srb=new SpringResourceBundle();
		srb.init(pageContext.getRequest().getLocale());
		this.label =srb.getMessage(label);
	}
	
}
